home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / ewl / examples / ewl_menu_test.c < prev    next >
C/C++ Source or Header  |  2006-01-09  |  3KB  |  103 lines

  1. #include "ewl_test.h"
  2.  
  3. static Ewl_Widget *menu_button = NULL;
  4.  
  5. static void
  6. __destroy_menu_test_window(Ewl_Widget * w, void *ev_data __UNUSED__,
  7.                         void *user_data __UNUSED__)
  8. {
  9.     ewl_widget_destroy(w);
  10.     ewl_callback_append(menu_button, EWL_CALLBACK_CLICKED,
  11.                 __create_menu_test_window, NULL);
  12. }
  13.  
  14. static void
  15. __menu_focus_in(Ewl_Widget * w, void *ev_data __UNUSED__,
  16.                     void *user_data __UNUSED__)
  17. {
  18.     const char *text;
  19.  
  20.     text = ewl_label_text_get(EWL_LABEL(EWL_MENU_ITEM(w)->text));
  21.     printf("%s item down\n", text);
  22. }
  23.  
  24. void
  25. __create_menu_test_window(Ewl_Widget *w, void *ev_data __UNUSED__,
  26.                     void *user_data __UNUSED__)
  27. {
  28.     Ewl_Widget     *menu_win;
  29.     Ewl_Widget     *menu1, *menu2;
  30.     Ewl_Widget     *item;
  31.  
  32.     menu_button = w;
  33.  
  34.     menu_win = ewl_window_new();
  35.     ewl_window_title_set(EWL_WINDOW(menu_win), "Menu Test");
  36.     ewl_window_name_set(EWL_WINDOW(menu_win), "EWL Test Application");
  37.     ewl_window_class_set(EWL_WINDOW(menu_win), "EFL Test Application");
  38.  
  39.     if (w) {
  40.         ewl_callback_del(w, EWL_CALLBACK_CLICKED, 
  41.                     __create_menu_test_window);
  42.         ewl_callback_append(menu_win, EWL_CALLBACK_DELETE_WINDOW,
  43.                     __destroy_menu_test_window, NULL);
  44.     } else
  45.         ewl_callback_append(menu_win, EWL_CALLBACK_DELETE_WINDOW,
  46.                     __close_main_window, NULL);
  47.     ewl_widget_show(menu_win);
  48.  
  49.     /*
  50.      * Create the menu
  51.      */
  52.     menu1 = ewl_menu_new();
  53.     ewl_menu_item_image_set(EWL_MENU_ITEM(menu1), PACKAGE_DATA_DIR "/images/Draw.png");
  54.     ewl_menu_item_text_set(EWL_MENU_ITEM(menu1), "test menu");
  55.     ewl_container_child_append(EWL_CONTAINER(menu_win), menu1);
  56.     ewl_widget_show(menu1);
  57.  
  58.     /*
  59.      * Append some test items
  60.      */
  61.     item = ewl_menu_item_new();
  62.     ewl_menu_item_image_set(EWL_MENU_ITEM(item), PACKAGE_DATA_DIR "/images/Open.png");
  63.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "dia");
  64.     ewl_container_child_append(EWL_CONTAINER(menu1), item);
  65.     ewl_callback_append(item, EWL_CALLBACK_FOCUS_IN, __menu_focus_in, NULL);
  66.     ewl_widget_show(item);
  67.  
  68.     item = ewl_menu_item_new();
  69.     ewl_menu_item_image_set(EWL_MENU_ITEM(item), PACKAGE_DATA_DIR "/images/Package.png");
  70.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "gimp");
  71.     ewl_container_child_append(EWL_CONTAINER(menu1), item);
  72.     ewl_callback_append(item, EWL_CALLBACK_FOCUS_IN, __menu_focus_in, NULL);
  73.     ewl_widget_show(item);
  74.  
  75.     item = ewl_menu_item_new();
  76.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "button");
  77.     ewl_container_child_append(EWL_CONTAINER(menu1), item);
  78.     ewl_callback_append(item, EWL_CALLBACK_FOCUS_IN, __menu_focus_in, NULL);
  79.     ewl_widget_show(item);
  80.  
  81.     /*
  82.      * Create a sub-menu
  83.      */
  84.     menu2 = ewl_menu_new();
  85.     ewl_menu_item_text_set(EWL_MENU_ITEM(menu2), "Sub menu");
  86.     ewl_container_child_append(EWL_CONTAINER(menu1), menu2);
  87.     ewl_widget_show(menu2);
  88.  
  89.     item = ewl_menu_item_new();
  90.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "button 1");
  91.     ewl_container_child_append(EWL_CONTAINER(menu2), item);
  92.     ewl_callback_append(item, EWL_CALLBACK_FOCUS_IN, __menu_focus_in, NULL);
  93.     ewl_widget_show(item);
  94.  
  95.     item = ewl_menu_item_new();
  96.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "button 2");
  97.     ewl_container_child_append(EWL_CONTAINER(menu2), item);
  98.     ewl_callback_append(item, EWL_CALLBACK_FOCUS_IN, __menu_focus_in, NULL);
  99.     ewl_widget_show(item);
  100. }
  101.  
  102.  
  103.